<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../day8/jquery-3.4.1.min.js"></script>
		<script>
		 $(function(){
			 $("#btn").click(function(){
				 var u=$("#name");
				 let name=u[0];
				 let reg=/\d+/g;
				 //alert(55);
				 //let name=document.getElementById("name");
				 
				 if(name.validity.valueMissing){
					 name.setCustomValidity("姓名不能不填！");
					 //return false;
				 }else if(name.validity.tooLong){
					 name.setCustomValidity("姓名长度在2-10个字符之间，您输入的是 "+name.value.length+"个");
					 //return false;
				 }else if(name.validity.patternMismatch){
					 name.setCustomValidity("姓名长度在2-10个字符之间，您输入的是 "+name.value.length+"个");
					 //return false;
				 }else if(reg.test(name.value)){
					 name.setCustomValidity("姓名中不能有数字！");
					 //return false;
				 }else{
					 name.setCustomValidity("");
				 }
				 
				 //return true;
			 });
		 })
		</script>
	</head>
	<body>
		<form action="33.html" id="regForm">
			<p>
				<input autocomplete="off" id="name" type="text" name="name" placeholder="姓名" required="required" pattern=".{2,10}">
			</p>
			<p>
				<input type="submit" id="btn" value="注册"/>
			</p>
		</form>
	</body>
</html>
